<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>isBooleanAttr</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const isBooleanAttr = key => {
            const boolAttr = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`;
            return boolAttr.split(',').includes(key);
        }
        console.log(isBooleanAttr('required')); // true;
        console.log(isBooleanAttr('id')); // false;
    </script>
</body>

</html>